package com.zhijian.warehouse.manage.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author HCG
 * @version 1.0
 * @date 2024-10-20
 */
public class StoreEnum {

    /**
     * 状态枚举类
     */
    @AllArgsConstructor
    @Getter
    public enum StatusEnum {

        DRAFT(0, "草稿"),
        WAIT_APPROVE(1, "待审核"),
        END(2, "已完成"),
        REJECT(9, "已驳回"),;

        private Integer code;
        private String desc;

        public static StatusEnum getByCode(Integer code) {
            StatusEnum[] values = StatusEnum.values();
            for (StatusEnum anEnum : values) {
                if (anEnum.getCode().equals(code)) {
                    return anEnum;
                }
            }
            return null;
        }

    }
    
    /**
     * 状态枚举类
     */
    @AllArgsConstructor
    @Getter
    public enum STOCK_STATUS_TYPE {

        DRAFT(0, "未盘点"),
        WAIT_APPROVE(1, "盘点中"),
        END(2, "盘点完成"),
        STOCK_CHECKING(3, "待亏盈处理"),
        ;

        private Integer code;
        private String desc;

        public static STOCK_STATUS_TYPE getByCode(Integer code) {
            STOCK_STATUS_TYPE[] values = STOCK_STATUS_TYPE.values();
            for (STOCK_STATUS_TYPE anEnum : values) {
                if (Objects.equals(anEnum.getCode(), code)) {
                    return anEnum;
                }
            }
            return null;
        }
    }

    /**
     * 状态枚举类
     */
    @AllArgsConstructor
    @Getter
    public enum STOCK_TYPE {
        //0 = 盘平单 1 = 盘盈单 2 = 盘亏单
        BALANCE(0, "原始单"),
        PROFIT(1, "盘盈单"),
        LOST(2, "盘亏单"),
        ;

        private Integer code;
        private String desc;

        public static StoreEnum.STOCK_TYPE getByCode(Integer code) {
            StoreEnum.STOCK_TYPE[] values = StoreEnum.STOCK_TYPE.values();
            for (StoreEnum.STOCK_TYPE anEnum : values) {
                if (Objects.equals(anEnum.getCode(), code)) {
                    return anEnum;
                }
            }
            return null;
        }

    }

    /**
     * 状态枚举类
     */
    @AllArgsConstructor
    @Getter
    public enum LOCK_TYPE {
        //0 = 盘平单 1 = 盘盈单 2 = 盘亏单
        UNLOCKED(0, "未锁定"),
        LOCK(1, "已锁定"),
        ;

        private Integer code;
        private String desc;

        public static LOCK_TYPE getByCode(Integer code) {
            LOCK_TYPE[] values = LOCK_TYPE.values();
            for (LOCK_TYPE anEnum : values) {
                if (Objects.equals(anEnum.getCode(), code)) {
                    return anEnum;
                }
            }
            return null;
        }

    }
    
    /**
     * 状态枚举类
     */
    @AllArgsConstructor
    @Getter
    public enum ALLOT_PRODUCT_STATUS {
        //0 = 盘平单 1 = 盘盈单 2 = 盘亏单
        REVIEW(0, "待审核"),
        OUT(1, "待出库"),
        IN(2, "待入库"),
        END(3, "已完成"),
        ;

        private Integer code;
        private String desc;

        public static ALLOT_PRODUCT_STATUS getByCode(Integer code) {
            ALLOT_PRODUCT_STATUS[] values = ALLOT_PRODUCT_STATUS.values();
            for (ALLOT_PRODUCT_STATUS anEnum : values) {
                if (Objects.equals(anEnum.getCode(), code)) {
                    return anEnum;
                }
            }
            return null;
        }

    }

    /**
     * 状态枚举类
     */
    @AllArgsConstructor
    @Getter
    public enum IN_OUT_TYPE {
        //0 = 盘平单 1 = 盘盈单 2 = 盘亏单
        OUT(-1, "出库"),
        IN(1, "入库"),

        ;

        private Integer code;
        private String desc;

        public static IN_OUT_TYPE getByCode(Integer code) {
            IN_OUT_TYPE[] values = IN_OUT_TYPE.values();
            for (IN_OUT_TYPE anEnum : values) {
                if (Objects.equals(anEnum.getCode(), code)) {
                    return anEnum;
                }
            }
            return null;
        }

    }
}
